package com.mitake.task.day5;

import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue;

import com.mitake.parse.Day5;
import com.mitake.parse.Day5.Day5Item;
import com.mitake.utils.Util;

public class Day5CompareProcess {
	
	//public static ArrayList<Day5[]> store =new ArrayList<Day5[]>();
	public static Day5[]  data  = null;

	
	public static void compare(Day5[] day5s){
		for(int i = 1, len = day5s.length-1; i<len; i++){
			compareItem(day5s, day5s[i].day5Map, day5s[i+1].day5Map);
		}
		//store.add(day5s);
		data = day5s;
	}
	
	private static void compareItem(Day5[] day5s, Map<String,Day5Item> day5_1,Map<String,Day5Item> day5_2){
		for(String key : day5_1.keySet()){
			 Day5Item day5Item = day5s[0].day5Map.get(key);
			 if(day5Item == null){
				 day5Item =new Day5Item();
				 day5s[0].day5Map.put(key, day5Item);
			 }
			 
			if(day5_1.get(key) == null || day5_2.get(key) == null){
				day5Item.lastPrice = "@";
				day5Item.volume = "@";
				continue;
			}
			
			if( Util.hasDifference(day5_1.get(key).lastPrice, day5_2.get(key).lastPrice)){
				day5Item.lastPrice = "@";
			}
			if( Util.hasDifference(day5_1.get(key).volume, day5_2.get(key).volume)){
				day5Item.volume = "@";
			}
		}
	}
}
